<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="/web/js/global/global_header.js"></script>
    <title>华锐Pms</title>
</head>

<body>
    <div id="app" class="" v-cloak>
        <el-dialog title="酒店修改" :visible.sync="dialogFormVisible" width="30%" @closed="CL()">
            <el-form :model="form" label-width="100px" size="small" :rules="rules" ref="ruleForm">
                <el-form-item label="酒店名称" prop="name">
                    <el-input v-model="form.name" autocomplete="off" placeholder="如：维多利亚酒店"></el-input>
                </el-form-item>
                <el-form-item label="酒店地址" prop="address">
                    <el-input v-model="form.address" autocomplete="off" placeholder="如：清远市清城区凤翔大道11路"></el-input>
                </el-form-item>
                <el-form-item label="联系人" prop="contacts">
                    <el-input v-model="form.contacts" autocomplete="off" placeholder="如：张小四"></el-input>
                </el-form-item>
                <el-form-item label="联系人电话" prop="telephone">
                    <el-input v-model="form.telephone" autocomplete="off" placeholder="如：15962205774"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisible = false" size="small" class="tx-14">取 消</el-button>
                <el-button type="primary" @click="submitForm('ruleForm')" size="small" class="tx-14">提交</el-button>
            </div>
        </el-dialog>
    </div>
    <script type="text/babel">
        new Vue({
            el: '#app',
            data: {
                dialogFormVisible: false,
                form: {
                    id: Pms.getParameter("id"),
                    name: "",
                    address: "",
                    contacts: "",
                    telephone: "",
                },
                rules: {
                    name: [
                        { required: true, message: '请填写酒店名称', trigger: 'blur' },
                    ],
                    address: [
                        { required: true, message: '请填写酒店地址', trigger: 'blur' }
                    ],
                    contacts: [
                        { required: true, message: '请填写联系人', trigger: 'blur' }
                    ],
                    telephone: [
                        { required: true, message: '请填写联系人电话', trigger: 'blur' },
                    ]
                }
            },
            mounted() {
                this.dialogFormVisible = true
            },
            created() {
                if (this.form.id) {
                    this.GET({ url: top.Config.curUrl + "/bst/bstHotel/get", map: this.form }).then((res) => {
                        if (res.retcode == 200) { //如果返回码不是200则提示错误登录信息
                            this.form = res.result.bean;
                        } else { //如果返回码是200则登录成功
                            this.msgError(res.retmsg)
                        }
                    })
                }

            },
            methods: {
                submitForm(formName) {
                    this.$refs[formName].validate((valid) => {
                        if (valid) {
                            this.startLoading("加载中", { background: "rgba(0, 0, 0, 0)", target: document.getElementsByClassName("el-dialog")[0] }, this)
                            this.POST({ url: top.Config.curUrl + "/bst/bstHotel/save", map: this.form }).then((res) => {
                                if (res.retcode == 200) { //如果返回码不是200则提示错误登录信息
                                    setTimeout(() => {
                                        this.Refresh("vm.getList()")
                                        this.closeLoading();
                                        this.dialogFormVisible = false;
                                    }, 1000);
                                } else { //如果返回码是200则登录成功
                                    this.msgError(res.retmsg);
                                    this.closeLoading();
                                }
                            })
                        }
                    });
                },
            }
        })
    </script>

</body>

</html>